package com.mys.dxc;
/*
 * 暂未明白程序运行意图
 */

import java.io.*;
import java.net.*;

public class Both {
	public static void main(String args[])
	{
		final String urlString = "http://www.gznet.com";
		final String message = "aaa";
		Thread thread1 = new Thread()
		{
			public void run()
			{
				try
				{
					URL url = new URL(urlString);
					URLConnection connection = url.openConnection();
					InputStreamReader isr = new InputStreamReader(connection.getInputStream());
					BufferedReader reader = new BufferedReader(isr);
					int count = 0;
					while (reader.read() != -1)
					{
						
						count++;
						
					}
					System.out.println("Size is : " + count);
					reader.close();
				}
				catch (MalformedURLException e)
				{
					System.err.println("Bad URL: " + urlString);
				}
				catch (IOException e)
				{
					System.err.println("I/O Problems");
				}
				
			}
		};
		thread1.start();
		Runnable runnable = new Runnable()
		{
			public void run()
			{
				while (true)
				{
					System.out.println(message);
					try
					{
						Thread.sleep(500);
						
					}
					catch (InterruptedException e)
					{
						
					}
				}
				
			}
		};
		Thread thread2 = new Thread(runnable);
		thread2.start();
		try
		{
			System.out.println("Press ENTER to stop");
			System.in.read(new byte[10]);
		}
		catch (IOException e)
		{
			System.out.println("I/O problems");
			
		}
		System.exit(0);
		
	}
}